import styles from './index.less';
import { Flex } from 'antd-mobile';
import prevImgSrc from './up.svg';
import nextImgSrc from './down.svg';
import {connect} from 'dva'
export default connect(state => ({}))(function pagination(pageProps) {
  let { type } = pageProps;
  let imgSrc = type === 'prev' ? prevImgSrc : nextImgSrc;
  const handleClick = ()=> {
    if(pageProps.index !== null){
      pageProps.dispatch({
        type: 'cms/changeCurrentPostObj',
        payload: pageProps.index
      })
      // pageProps.handleScrollTop()
    }else{
      console.log("​handleClick -> pageProps.index ", pageProps.index )
    }
  }
  return (
    <Flex direction="column" align="stretch" className={styles.container} onClick={handleClick}>
      <Flex className={styles.header}>
        <Flex.Item>
          <img src={imgSrc} className={styles.icon} />
          {type === 'prev' ? <span>上一条</span> : <span>下一条</span>}
        </Flex.Item>
        <div>{pageProps.postTime}</div>
      </Flex>
      <Flex.Item>{pageProps.title}</Flex.Item>
    </Flex>
  );
})
